/*
 *--------------------------------------------------------------------------
 *   Battlefield - A Realtime Network Multiplayer Game
 *   =======================================================
 *   Developed by Group D02 - 2009/2010 Semester 4 - CS2103
 *     Harry Nguyen Duy Hoang <nnduyhoang@yahoo.co.uk>
 *     Kent Chng Siang Rong <fivefootway@gmail.com>
 *     Lim Yong Peng <limpeng1986@gmail.com>
 *     Loh Xiankun <u0807185@nus.edu.sg>
 *   Instructed by
 *     Dr. Damith C.Rajapakse <damith@gmail.com>
 *   =======================================================
 *   $Id: ArrayUtils.java 600 2010-07-26 17:08:16Z Harry $
 *   $LastChangedDate: 2010-07-26 17:08:16 +0000 (Mon, 26 Jul 2010) $
 *   $LastChangedBy: Harry $
 *--------------------------------------------------------------------------
 */
package battlefield.util;

/**
 *
 * @author Harry Nguyen
 */
public class ArrayUtils {

    public static int indexOf(Object[] objects, Object object) {
        if (objects == null || object == null) {
            return -1;
        }

        for (int i = 0; i < objects.length; i++) {
            if (object.equals(objects[i])) {
                return i;
            }
        }

        return -1;
    }

    public static boolean contains(Object[] objects, Object object) {
        return indexOf(objects, object) >= 0;
    }
}
